package net.javalib.flickr.search;

import net.javalib.flickr.search.flickr.FlickrImage;

/**
 * Class used to control downloads.
 * In practice this would have more stuff in it, such as
 * wether or not to cache the image etc... It would also
 * be more generic.
 */
public class DownloadInfo {
	/** The image being downloaded */
	public FlickrImage image;
	/** Is this a thumbnail download */
	public boolean isThumbnail;
	
	/**
	 * Constructor
	 */
	public DownloadInfo(FlickrImage image, boolean isThumbnail) {
		this.image = image;
		this.isThumbnail = isThumbnail;
	}
	
	/**
	 * The cacheKey under which the image data will be stored in the cache.
	 */
	public String getCacheKey() {
		return getCacheKey(image,isThumbnail);
	}
	
	/**
	 * The url for this download
	 * @return
	 */
	public String getURL() {
		if (isThumbnail)
			return image.getThumbnailURL();
		return image.getURL();
	}
	
	/**
	 * The cacheKey under which the image data will be stored in the cache.
	 */
	public static String getCacheKey(FlickrImage image, boolean isThumbnail) {
		if (isThumbnail)
			return "tn-"+image.id;
		return "i-"+image.id;
		
	}
	
}
